package site.weiyikai.eventdriven.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import site.weiyikai.eventdriven.core.EventService;
import site.weiyikai.eventdriven.core.EventSubscriber;
import site.weiyikai.eventdriven.factory.SubscriberFactoryBean;
import javax.annotation.Resource;
import java.util.Set;


/**
 * 描述：订阅服务配置类
 *
 * @author 程序员小魏
 * 创建时间: 2023/11/11
 */
@Configuration
public class SubscriberConfig {

    private final Set<EventSubscriber<?>> eventSubscribers;

    @Resource
    private EventService eventService;

    public SubscriberConfig(Set<EventSubscriber<?>> eventSubscribers) {
        this.eventSubscribers = eventSubscribers;
    }

    @Bean
    public SubscriberFactoryBean outboundRequestSubscriber() {
        return new SubscriberFactoryBean(eventSubscribers, eventService);
    }

}
